package com.dong.feign.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.dong.controller.R;
import com.dong.exceptions.ExceptionUtil;
import com.dong.feign.FeignConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/feign")
public class FeignUserController {
    @Autowired
    FeignConfig feignConfig;

    @SentinelResource(value = "getUser",
            fallback = "fallback",fallbackClass = ExceptionUtil.class,
            blockHandler = "handleException",blockHandlerClass = ExceptionUtil.class
    )
    @GetMapping("/getUser/{id}")
    public R getUser(@PathVariable("id") Integer id){
        return feignConfig.findOrderByUserId(id);
    }
}
